﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>jQuery Object Accessors</title>
    <script src="script/jquery-1.3.2.js" type="text/javascript"></script>
    <script language="javascript" type="text/javascript">
        $(document).ready(function() {
            $("#btn").click(function() {
                Hitung();
            });
        });

        function Hitung() {
            var inputs = $("div > input").get();
            var jumlah = parseInt(0);

            for (var i = 0; i < $("div > input").size(); i++) {
                jumlah = parseInt(jumlah) + parseInt(inputs[i].value);
            }

            $("#jumlah").val(jumlah);
        }
    </script>
</head>
<body>
    <div style="border:dashed 1px Gray;padding:13px">
    Biaya 1 : <input type="text" /><br />
    Biaya 2 : <input type="text" /><br />
    Biaya 3 : <input type="text" /><br />
    </div>
    <br /><br />
    Jumlah <input type="text" id="jumlah" /> <input id="btn" type="button" value="Hitung" />
</body>
</html>
